package com.ymx.darling.spring.transaction;

import com.ymx.darling.transaction.Transaction;
import com.ymx.darling.transaction.TransactionManager;

import javax.sql.DataSource;

/**
 * @author 爱Java的小于
 */
public class SpringTransactionManager implements TransactionManager {
    private final DataSource dataSource;

    public SpringTransactionManager(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    public DataSource getDataSource() {
        return this.dataSource;
    }

    @Override
    public Transaction createTransaction(boolean isAutoCommit) {
        return new SpringTransaction(dataSource);
    }
}
